<template>
  <div class="home">
    <van-nav-bar
      title="返校申请"
      left-text="返回"
      left-arrow
      @click-left="$router.go(-1)"
    />
    <van-list
      v-model:loading="loading"
      :finished="finished"
      finished-text="没有更多了"
      @load="onLoad"
    >
      <div style="margin: 16px">
        <van-button @click="pushResidentList()" block type="info">
          <!-- native-type="submit" -->
          <van-icon name="plus" /> 提交申请
        </van-button>
      </div>

      <!-- title="商品标题"   num="2"
   thumb="https://img.yzcdn.cn/vant/ipad.jpeg"-->
      <van-card
        desc="描述信息"
        @click="trafficInfo(index)"
        v-for="(item, index) in list"
        :key="index"
        :title="item"
      >
        <template #tags>

          <!-- <van-cell value="确定这个">
            <template #right-icon>
              <van-icon name="cross" class="search-icon" />
            </template>
          </van-cell> -->
          <van-row>
  <van-col span="8">span: 8</van-col>
  <van-col span="8">span: 8</van-col>
  <van-col span="8">span: 8</van-col>
</van-row>

<van-row>
  <van-col span="4">span: 4</van-col>
  <van-col span="10" offset="4">offset: 4, span: 10</van-col>
</van-row>
        </template>
        <template #footer>
          <van-button size="mini">确认</van-button>
          <van-button size="mini">拒绝</van-button>
        </template>
      </van-card>

      <van-cell />
    </van-list>
    <div id="box"></div>
  </div>
</template>

<script>
import { areaList } from '@vant/area-data'
import area from '@/libs/area.json'
import { helpUserInsert } from '@/api/self/record'
import { Toast, Dialog } from 'vant'
export default {
  data () {
    return {
      list: [],
      loading: false,
      finished: false
    }
  },
  mounted () {
    // getCurrentPosition与定时器setInterval类似多次请求，因为位置需要不间断的获取
    // 直接navigator.geolocation表示单次获取位置
    let btn = document.getElementById('btn')
    let box = document.getElementById('box')
    navigator.geolocation.getCurrentPosition(
      function (position) {
        box.innerHTML += '经度' + position.coords.longitude
        box.innerHTML += '纬度' + position.coords.latitude
        box.innerHTML += '准确度' + position.coords.accuracy
        box.innerHTML += '海拔' + position.coords.altitude
        box.innerHTML += '海拔准确度' + position.coords.altitudeAcuracy
        box.innerHTML += '行进方向' + position.coords.heading
        box.innerHTML += '地面速度' + position.coords.speed
        box.innerHTML += '请求的时间' + new Date(position.timestamp)
      },
      function (err) {
        console.log(err.code)
        // code：返回获取位置的状态
        //          0  :  不包括其他错误编号中的错误
        // ​		     1  :  用户拒绝浏览器获取位置信息
        // ​		     2  :  尝试获取用户信息，但失败了
        // ​		     3  :   设置了timeout值，获取位置超时了
      },
      {
        enableHighAcuracy: false, // 位置是否精确获取
        timeout: 5000, // 获取位置允许的最长时间
        maximumAge: 1000 // 多久更新获取一次位置
      }
    )
  },
  methods: {
    onLoad () {
      setTimeout(() => {
        for (let i = 0; i < 10; i++) {
          this.list.push(this.list.length + 1)
        }
        // 加载状态结束
        this.loading = false
        // 数据全部加载完成
        if (this.list.length >= 40) {
          this.finished = true
        }
      }, 1000)
    },
    trafficInfo (id) {
      this.$router.push({ name: 'traffic-transship-info', query: { id: id } })
    }
  }
}
</script>
<style lang="less" scoped>
.upload-img-5 {
  margin: 5px 0 90px 0;
}
.upload-img-1 {
  margin: 5px 0 15px 0;
}

.home {
  // background: url('../../assets/images/smtb.jpg') no-repeat;

  img {
    // background: url('../../assets/images/smtb.jpg');
    width: 100%;
  }
  .dialog-container {
    height: 70vh;
    overflow-y: auto;
  }
  .get-area {
    width: 100%;
    padding: 0 0.8rem;
    font-size: 0.747rem;
    color: #fff;
    background-color: #1989fa;
    border: 0.053rem solid #1989fa;
    height: 2.347rem;
    line-height: 2.347rem;
    text-align: center;
    border-radius: 0.107rem;
    cursor: pointer;
    box-sizing: border-box;
    margin-right: 10px;
  }
  /deep/.van-field__label {
    width: 8em;
  }
  /deep/.van-field__error-message {
    text-align: right;
  }
  .title {
    // font-size: 28px;
    text-indent: 20px;
    padding: 50px 0 20px;
  }
  .container {
    width: 90%;
    height: 80vh;
    overflow-y: auto;
    border: 1px solid #adadad;
    margin: auto;
    .item {
      margin: 10px;
    }
  }
}
.up-and-down {
  display: flex;
  justify-content: center;
  align-items: center;
  background: #f1f3f4;
  height: 80px;
  color: #333;
}
.home .blue {
  background-color: transparent;
}
.home .van-cell {
  background-color: transparent;
}
</style>
